<template>
  <div>
    <div class="item" v-for="(item, index) of list" :key="index">
      <div class="item-title border-bottom">
        <span class="item-title-icon"></span>
        <span class="item-title-right">{{item.title}}</span>
      </div>
      <div v-for="(a, b) in item.children" :key="b">
        <div class="item-title border-bottom item-title-2" @click="showDetail(a)">
          <span class="item-title-right">{{a.title}}</span>
          <span class="iconfont" v-show="!a.isShow">&#xe613;</span>
          <span class="iconfont" v-show="a.isShow">&#xe6bf;</span>
        </div>
        <div v-show="a.isShow">
          <div class="item-title border-bottom item-title-3" v-for="(i, j) in a.children" :key="j">
            <span class="item-title-right">{{i.title}}</span>
          </div>
        </div>
      </div>
      <!-- 递归组件用法 -->
      <!-- <div v-if="item.children">
        <detail-list :list="item.children"></detail-list>
      </div>-->
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailList',
  props: {
    list: Array
  },
  data() {
    return {
      showTitle: false
    }
  },

  methods: {
    showDetail(val) {
      val.isShow = !val.isShow
    }
  }
}
</script>
<style lang="stylus" scoped>
@import '~styles/varibles.styl';

.border-bottom {
  &:before {
    border-color: #e0e0e0;
  }
}

.item {
  border-bottom: 0.18rem solid #F5F5F5;

  .item-title {
    display: flex;
    align-items: center;
    line-height: 0.8rem;
    font-size: 0.32rem;
    padding: 0.2rem;

    .item-title-icon {
      position: relative;
      display: inline-block;
      width: 0.36rem;
      height: 0.36rem;
      background: url('http://s.qunarzz.com/piao/image/touch/sight/detail.png') 0 -0.45rem no-repeat;
      background-size: 0.4rem 3rem;
      padding-left: 0.05rem;
    }

    .item-title-right {
      display: inline-block;
    }
  }

  .item-title-2 {
    margin-left: 0.05rem;
    margin-right: 0.2rem;
    justify-content: space-between;
  }

  .item-title-3 {
    background: #F5F5F5;
    padding-left: 0.25rem;
    font-size: 0.28rem;
  }

  .item-children {
    // padding: 0 0.2rem;
    background: #ddd;
  }
}
</style>
